home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sprite 1984 - 1993
/
Sprite 1984 - 1993.iso
/
src
/
lib
/
c
/
stdio
/
tmpnam.man
< prev
next >
Wrap
Text File
|
1989-10-03
|
3KB
|
70 lines
' Copyright 1989 Regents of the University of California
' Permission to use, copy, modify, and distribute this
' documentation for any purpose and without fee is hereby
' granted, provided that this notice appears in all copies.
' The University of California makes no representations about
' the suitability of this material for any purpose. It is
' provided "as is" without express or implied warranty.
'
' $Header: /sprite/src/lib/c/stdio/RCS/tmpnam.man,v 1.2 89/10/03 17:29:09 shirriff Exp $ SPRITE (Berkeley)
'
.so \*(]ltmac.sprite
.HS tmpnam lib
.BS
.SH NAME
tmpnam, tempnam \- Generate unique names for temporary files
.SH SYNOPSIS
.nf
\fBinclude <stdio.h>
\fBchar *
tmpnam(\fIs\fR)
\fBchar *
tempnam(\fIdir\fR, \fIprefix\fR)
.SH ARGUMENTS
.AS char *prefix
.AP char *s in/out
Place to store temporary file name. If \fBNULL\fR, store name in local
static storage that will be overwritten on next call to \fBtmpnam\fR.
If not \fBNULL\fR, \fIs\fR must point to a buffer containing
at least \fBL_tmpnam\fR bytes.
.AP char *dir in
Directory in which to temporary file should reside. If \fBNULL\fR,
or if \fIdir\fR is not an accessible directory, defaults to \fBP_tmpdir\fR.
.AP char *prefix in
First few letters to use for name of temporary file.
.BE
.SH DESCRIPTION
.PP
The procedures \fBtmpnam\fR and \fBtempnam\fR generate unique file
names suitable for temporary files. Each procedure returns a pointer
to the name it generated, except that under some conditions (such
as inability to allocate memory, for example) \fBtempnam\fR will
fail to generate a file name. When this happens, \fBtempnam\fR will
return \fBNULL\fR.
.PP
\fBTmpnam\fR generates file names that refer to a standard directory
defined by \fBP_tmpdir\fR (currently \fB/usr/tmp\fR). Each time
\fBtmpnam\fR is called it will return a different file name, which
does not refer to any existing file.
.PP
\fBTempnam\fR is similar to \fBtmpnam\fR except that it provides
more flexibility. The \fIdir\fR argument may be used to specify
a particular directory to which the generated name should refer.
If this is not an accessible directory, then \fBP_tmpdir\fR will
be used. If this directory is not accessible either, then
\fB/tmp\fR will be used as a last resort. If the \fBTMPDIR\fR
environment variable is defined and refers to an accessible
directory, then it will override any of the above choices.
.PP
The \fIprefix\fR argument may be used to specify the first few letters
of the last component of the path name generated by \fBtempnam\fR.
\fBTempnam\fR dynamically allocates space for the name
using \fBmalloc\fR. It is the responsibility of the caller to
release this storage by passing the returned string to \fBfree\fR
when it is no longer needed.
.SH KEYWORDS
file name, temporary, unique